//	ID : pallab81
// 	PROG : 108
// 	LANG : C++
// 	2011-08-29-09.11.59 Monday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foR(i,st,ed) for(int i = st ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait( double seconds ){
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ){
        ;
    }
}
int N;
vector< VI > g;
vector< VI > ps; // prefix sum

inline void Print(){
    fo(i,N){
        fo(j,N){
            printf("%d  ",ps[i][j]);
        }
        printf("\n");
    }
    printf("\n");
}
inline void Read(){
    g.assign(N, VI(N,0) );
    fo(i,N){
        fo(j,N){
            CI(g[i][j]);
        }
    }
}
inline void VerticalPrefixSum(){
    ps.assign(N, VI(N,0) );
    fo(col,N){
        int sum=0;
        fo(row,N){
            sum+= g[row][col];
            ps[row][col]=sum;
        }
    }
}
inline int Kadane(){
    int maxSum = (int)-1e9;
    for(int rowa=0; rowa<N;++rowa){
        for(int rowb=0; rowb<=rowa;++rowb){
            int currentMaxSum=0;
            for(int col=0;col<N;++col){
                currentMaxSum+= ( ps[ rowa ][ col ] - ( rowb ? ps[ rowb-1 ][ col ] : 0 ) );
                if( currentMaxSum > maxSum ){
                    maxSum = currentMaxSum;
                }
                //printf("Current max sum %d %d %d %d\n",rowb,rowa,col,currentMaxSum);wait(.5);
                if(currentMaxSum<0){
                    currentMaxSum=0;
                }
            }
        }
    }
return maxSum;
}
inline void Proc(){
    VerticalPrefixSum();
    //Print();
    int var = Kadane();
    printf("%d\n",var);
}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("in.txt","rt",stdin);
    #endif

    while( scanf("%d",&N)==1 ){
        Read();
        Proc();
    }


return 0;
}
